<template>
<div>
   <h2>Add组件中的count: {{$store.state.count}}</h2>
   <button @click="mtAdd">+</button>
   <button @click="addN">+n</button>
   <button @click="addDx">对象</button>
   <button @click="addHs">函数</button>
   <button @click="addYb">异步调用Mutations</button>
   <button @click="addActionYb">调用actions</button>
</div>
</template>

<script>
import {mapMutations} from 'vuex'

export default {
   methods: {
      ...mapMutations(['mtAdd']),
      addN(){
         this.$store.commit('mtAddN',5)
      },
      addDx(){
         //this.$store.commit('mtDx',5)
         this.$store.commit({
            type: 'mtDx',
            name: 'hhh',
            age: 10
         })
      },
      addHs(){
         this.$store.commit('mtHs',function(id){
            console.log('我是函数：'+ id);
            return '函数返回值' + id
         })
      },
      addYb(){
        this.$store.commit('mtYb') //错误
        
      },
      addActionYb(){
         this.$store.dispatch('acAdd')
      }
   },

}
</script>

<style scoped>

</style>